/**
 * 行情分析js
 */

$(function() {
	initialPage();
	getGrid();
});

function initialPage() {
	$(window).resize(function() {
		$('#dataGrid').bootstrapTable('resetView', {
			height : $(window).height() - 56
		});
	});
}

function getGrid() {
	$('#dataGrid').bootstrapTableEx({
		url : '../../sys/quotationanalysis/list?_' + $.now(),
		height : $(window).height() - 56,
		queryParams : function(params) {
			params.name = vm.keyword;
			return params;
		},
		columns : [ {
			checkbox : true
		}, {
			field : "createTime",
			title : "创建时间",
			width : "100px"
		}, {
			field : "name",
			title : "标题",
			width : "100px"
		}, {
			field : "province",
			title : "省",
			width : "100px"
		}, {
			field : "author",
			title : "作者",
			width : "100px"
		}, {
			field : "status",
			title : "可用",
			width : "60px",
			align : "center",
			formatter : function(value, row, index) {
				if (value == 1) {
					return '<i class="fa fa-toggle-on"></i>';
				}
				if (value == 2) {
					return '<i class="fa fa-toggle-off"></i>';
				}
			}
		}, {
			field : "source",
			title : "来源",
			width : "100px"
		} ]
	})
}

var vm = new Vue(
		{
			el : '#dpLTE',
			data : {
				keyword : null
			},
			methods : {
				load : function() {
					$('#dataGrid').bootstrapTable('refresh');
				},
				save : function() {
					dialogOpen({
						title : '新增行情分析',
						url : 'base/quotationanalysis/add.html?_' + $.now(),
						width : '720px',
						height : '680px',
						yes : function(iframeId) {
							top.frames[iframeId].vm.acceptClick();
						},
					});
				},
				edit : function() {
					var ck = $('#dataGrid').bootstrapTable('getSelections');
					if (checkedRow(ck)) {
						dialogOpen({
							title : '编辑行情分析',
							url : 'base/quotationanalysis/edit.html?_'
									+ $.now(),
							width : '720px',
							height : '680px',
							success : function(iframeId) {
								top.frames[iframeId].vm.quotationAnalysis.id = ck[0].id;
								top.frames[iframeId].vm.setForm();
							},
							yes : function(iframeId) {
								top.frames[iframeId].vm.acceptClick();
							}
						});
					}
				},
				remove : function() {
					var ck = $('#dataGrid').bootstrapTable('getSelections'), ids = [];
					if (checkedArray(ck)) {
						$.each(ck, function(idx, item) {
							ids[idx] = item.id;
						});
						$.RemoveForm({
							url : '../../sys/quotationanalysis/remove?_'
									+ $.now(),
							param : ids,
							success : function(data) {
								vm.load();
							}
						});
					}
				}
			}
		})